using TMPro;
using UnityEngine;
using UnityEngine.UI;

namespace Minesweeper.GUI.HUD
{
    public class HudDataFiller : MonoBehaviour
    {
        public TMP_Text statistics, hpText, shovelDurabilityText;
        public Image hpFill, shovelDurabilityFill;

        private static GameGenerator GI => GameGenerator.Instance;
        private static Player PI => Player.Instance;
    
        private void Update()
        {
            statistics.text = $"清理方格数：{GI.ClearedGridCount}\n" +
                              $"发现雷数：{GI.MarkedMineCount + GI.DiggedMineCount} (已挖掘{GI.DiggedMineCount}个)\n" +
                              $"炸出了{GI.ExplodedMineCount}个弹坑";
            hpText.text = $"{PI.Health:0}/{PI.maxHealth:0}";
            shovelDurabilityText.text = $"{PI.ShovelDurability:0}/{PI.maxShovelDurability:0}";
            hpFill.fillAmount = PI.Health / PI.maxHealth;
            shovelDurabilityFill.fillAmount = PI.ShovelDurability / PI.maxShovelDurability;
        }
    }
}
